<?php

namespace app\model\group_activity;

use app\BaseModel;
use app\model\not_del\RatingScaleFactorLevelModel;
use app\model\not_del\RatingScaleFactorModel;
use app\model\not_del\RatingScaleFactorWarningModel;
use app\model\not_del\RatingScaleModel;
use think\model\relation\BelongsTo;

/**
 * 团体活动-测评因子得分
 */
class GroupActivityTaskUserResultFactorScoreModel extends BaseModel
{
    protected $name = 'group_activity_task_user_result_factor_score';

    /**
     * 关联量表
     * @return BelongsTo
     */
    public function RatingScale(): BelongsTo
    {
        return $this->belongsTo(RatingScaleModel::class, 'rating_scale_id')->bind([
            'rating_scale_name' => 'name',
        ]);
    }

    /**
     * 关联量表因子
     * @return BelongsTo
     */
    public function RatingScaleFactor(): BelongsTo
    {
        return $this->belongsTo(RatingScaleFactorModel::class, 'factor_id')->bind([
            'factor_name' => 'name',
            'formula_method',
            'factor_explain',
            'rating_scale_factor_level'
        ]);
    }

    /**
     * 关联量表因子等级
     * @return BelongsTo
     */
    public function RatingScaleFactorLevel(): BelongsTo
    {
        return $this->belongsTo(RatingScaleFactorLevelModel::class, 'factor_level_id')->bind([
            'factor_level_name' => 'name',
            'overview',
            'explain',
            'high_range'
        ]);
    }

    /**
     * 关联量表因子预警等级
     * @return BelongsTo
     */
    public function RatingScaleFactorWarning(): BelongsTo
    {
        return $this->belongsTo(RatingScaleFactorWarningModel::class, 'warning_id')->bind([
            'warning_name' => 'name',
        ]);
    }
}